' This script creates an action, which is equivalent to the Mosaic Tiles action
' and executes it.

Private Sub Command1_Click()

Dim appRef As Photoshop.Application
Dim filterDescriptor As Photoshop.ActionDescriptor
Dim retDescriptor As Photoshop.ActionDescriptor
Dim keyTileSizeID As String
Dim keyGroutWidthID As String
Dim keyLightenGroutID As String
Dim eventMosaicID As String

Dim adesc As Photoshop.ActionDescriptor
Dim actionRef As Photoshop.ActionReference
   

Set appRef = CreateObject("Photoshop.Application")

If (appRef.Documents.Count > 0) Then

    ' create an action and execute it.
    keyTileSizeID = appRef.CharIDToTypeID("TlSz")
    keyGroutWidthID = appRef.CharIDToTypeID("GrtW")
    keyLightenGroutID = appRef.CharIDToTypeID("LghG")
    eventMosaicID = appRef.CharIDToTypeID("MscT")
    
    Set filterDescriptor = CreateObject("Photoshop.ActionDescriptor")
    filterDescriptor.PutInteger Key:=keyTileSizeID, Value:=12
    filterDescriptor.PutInteger Key:=keyGroutWidthID, Value:=3
    filterDescriptor.PutInteger Key:=keyLightenGroutID, Value:=9
    
    Set retDescriptor = appRef.ExecuteAction(EventID:=eventMosaicID, Descriptor:=filterDescriptor, DialogOptions:=psDisplayNoDialogs)
    
End If

End Sub
